<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色增加页面</title>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>res/wzw/layui/css/layui.css" media="all">
<base href="<%=basePath%>">
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>增加角色</legend>
	</fieldset>

	<form class="layui-form" action="<%=basePath%>role/saveOrUpdate"
		method="post">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">角色名称</label>
				<div class="layui-input-inline">
					<input type="text" name="role_name" id="roleName" required
						lay-verify="required" placeholder="角色名称" autocomplete="off"
						class="layui-input" maxlength="10">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">角色编码</label>
				<div class="layui-input-block">
					<select name="role_code" id="roleCode" required lay-verify="required"
						autocomplete="off" class="layui-input">
						<option></option>
						<option value="gl">管理角色</option>
						<option value="dj">店家角色</option>
					</select>
				</div>
			</div>

		</div>

		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">角色描述</label>
				<div class="layui-input-inline">
					<input type="textarea" name="role_desc" id="roleDesc" required
						lay-verify="required" maxlength="11" placeholder="角色描述"
						autocomplete="off" class="layui-input" maxlength="10">
				</div>
			</div>

			<div class="layui-inline">
				<label class="layui-form-label">是否有效</label>
				<div class="layui-input-inline">
					<select name="isva" id="isva" required lay-verify="required"
						autocomplete="off" class="layui-input">
						<option></option>
						<option value="0">无效</option>
						<option value="1">有效</option>
					</select>
				</div>
			</div>
		</div>

		<!-- <div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">操作时间</label>
				<div class="layui-input-inline">
					<input type="date" name="optime" id="optime" required
						lay-verify="required"  autocomplete="off"
						class="layui-input">
				</div>
			</div> -->

		<div class="layui-inline">
			<label class="layui-form-label">操作人</label>
			<div class="layui-input-inline">
				<input type="text" name="oper" id="oper" required
					lay-verify="required" placeholder="操作人" autocomplete="off"
					class="layui-input" maxlength="10">
			</div>
		</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">赋予模块</label>
			<div id="ehyModel"></div>
		</div>

		<input type="hidden" id="str" name="str">
		<!-- 提交重置 -->
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input onclick="aa()" type="submit" class="layui-btn" lay-submit=""
					lay-filter="manAdd" value="立即提交">
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
		<!-- <input type="button" value="获取" onclick="aa()"> -->
	</form>
	<script src="<%=basePath %>res/wzw/layui/layui.js"></script>
	<script type="text/javascript" src="res/wzw/js/jquery.min.1.6.4.js"></script>
	<script src="<%=basePath%>js/jquery-1.10.2.js"></script>

	<script type="text/javascript">
	//赋值到INPUT
	function aa(){
		var bb="";
		var temp="";
		var a=document.getElementsByName("ro");
		//alert(a.length);
		for(var i=0;i<a.length; i++){
			if(a[i].checked){
				temp=a[i].value;
				if(bb==""){
					bb=temp;
				}else{
					bb=bb+","+temp;
				}
			}
		}
		//模块id字符串
		$("#str").val(bb);
		
		
	}
	
	layui.use(['form', 'layer'], function(){
		  var form = layui.form
		  ,layer = layui.layer
		  ,$ = layui.$;
		  
		  form.on('submit(manAdd)',function(){
			  parent.location.reload(); // 父页面刷新
		  });

		//查询所有模块
	  	var url = "<%=basePath%>role/findModel";
		$.post(url,null,function(data){
			data = data.data;
			// alert(data);
		for(var i=0;i<data.length;i++){
			$("#ehyModel").append("<input type='checkbox' value="+data[i].mod_id+" name='ro' title="+data[i].mod_name+">");
		}

			//form表单重新渲染
			form.render();
		},dataType="JSON");
	});
	</script>
</body>
</html>